package nl.concipit.sheetmusicarchive.model;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.validation.constraints.NotNull;

/**
 * Entity representing a join table linking Members to Bands.
 * 
 * The table includes information regarding the instrument played by the member
 * in the band, as well as an indication of the current state of membership.
 * 
 * @author David
 */
@Entity
public class BandMember {
	/**
	 * Band to which the member is associated
	 */
	@ManyToOne(fetch=FetchType.LAZY)
	  @JoinColumn(name="Id")
	private Band band;
	
	/**
	 * Member associated to the band
	 */
	@ManyToOne(fetch=FetchType.EAGER)
	@JoinColumn(name="Id")
	private Member member;
	
	/**
	 * Indicates whether the member is currently active in the band
	 */
	@NotNull
	private Boolean active;
	
	/**
	 * Indicates the instrument played by them member within the band
	 */
	@NotNull
	private String instrument;
	
	/**
	 * Default non-args constructor
	 */
	public BandMember() {
		super();
	}

	/**
	 * Returns the band to which the member is associated
	 * 
	 * @return the band
	 */
	public Band getBand() {
		return band;
	}

	/**
	 * Sets the band to which the member is associated
	 * 
	 * @param band the band to set
	 */
	public void setBand(Band band) {
		this.band = band;
	}

	/**
	 * Returns the member associated with the band
	 * 
	 * @return the member
	 */
	public Member getMember() {
		return member;
	}

	/**
	 * Sets the member associated with the band 
	 * 
	 * @param member the member to set
	 */
	public void setMember(Member member) {
		this.member = member;
	}

	/**
	 * Indicates whether the member is active within the band
	 * 
	 * @return the active
	 */
	public Boolean isActive() {
		return active;
	}

	/**
	 * Sets the indicator that the member is active within the band
	 * 
	 * @param active the active to set
	 */
	public void setActive(Boolean active) {
		this.active = active;
	}

	/**
	 * Returns the instrument played by the member within the band
	 * 
	 * @return the instrument
	 */
	public String getInstrument() {
		return instrument;
	}

	/**
	 * Sets the instrument played by the member within the band
	 * 
	 * @param instrument the instrument to set
	 */
	public void setInstrument(String instrument) {
		this.instrument = instrument;
	}	
}
